<?php
	require_once 'init.php';
	
	if(isset($_REQUEST['name']) || isset($_REQUEST['email']) || isset($_REQUEST['enquiry'])){
		if(!isset($_REQUEST['name']) || empty($_REQUEST['name'])){
			$message_name = "This field is required";
		}
		if(!isset($_REQUEST['email']) || empty($_REQUEST['email'])){
			$message_email = "This field is required";
		}
		if(!isset($_REQUEST['enquiry']) || empty($_REQUEST['enquiry'])){
			$message_enquiry = "This field is required";
		}
		if(isset($_REQUEST['name']) && isset($_REQUEST['email']) && isset($_REQUEST['enquiry']) &&
		   !empty($_REQUEST['name']) && !empty($_REQUEST['email']) && !empty($_REQUEST['enquiry'])){
				
			$from = "contacts@longtailcap.com";
			$to = "josephm@longtailcap.com";
			$subject = "New Contact Message";
			$body = "Name: ".$_REQUEST['name']."<br />";
			if(isset($_REQUEST['company']) && !empty($_REQUEST['company'])){
				$body = $body . "Company: ".$_REQUEST['company']."<br />";;
			}
			$body = $body . "Email: ".$_REQUEST['email']."<br />";
			$body = $body . "Enquiry: ".$_REQUEST['enquiry']."<br />";
			$headers = "From: $from\r\nContent-type: text/html\r\n";
			$ret = mail($to, $subject, $body, $headers);
			if(!ret) {
  				$message = "An error has ocurred while trying to send your mail. Please try again later.";
 			}else{
 				$message = "Your message has been sent";
 				$_REQUEST['name'] = "";
 				if(isset($_REQUEST['company']))
 					$_REQUEST['company'] = "";
 				$_REQUEST['email'] = "";
 				$_REQUEST['enquiry'] = "";
 			}
	    }
	}
?>
<html>
	<head>
		<title>Contact | Long Tail Capital</title>
		<META name="description" content="startup, seed capital, venture capital, raise capital, early stage company, business plans, marketing plans, financial projections, capital raise, angel investors">
		<META name="keywords" content="startup, seed capital, venture capital, raise capital, early stage company, business plans, marketing plans, financial projections, capital raise, angel investors">
		<link rel="stylesheet" type="text/css" href="resources/css/style.css" />
	</head>
	<body>
		<div class="main">
			<?php print_header();?>
			<div class="inBody">
				<table width="100%" cellspacing="0" cellpadding="0" border="0">
					<tr>
						<td width="225px">
							<?php
								$section_manager = new Section_manager($conn);
								print_menu($section_manager->getSectionsValues());
							?>
						</td>
						<td width="555px" height="300px" align="center">
							<img alt="longtailcap.com" src="resources/images/logo.jpg" border="0" height="200px" />
						</td>
					</tr>
				</table>
			</div>
			<div class="footer">
				<form action="contact.php" method="post">
					<div class="message"><?php echo (isset($message)?$message:""); ?></div>
					<div class="form">
						*Name<br />
						<input type="text" name="name" size="45" value="<?php echo (isset($_REQUEST['name'])?$_REQUEST['name']:""); ?>" />
						<div class="message"><?php echo (isset($message_name)?$message_name:""); ?></div>
					</div>
					<div class="form">
						Company<br/>
						<input type="text" name="company" size="45" value="<?php echo (isset($_REQUEST['company'])?$_REQUEST['company']:""); ?>" />
					</div>
					<div class="form">
						*Email<br />
						<input type="text" name="email" size="45" value="<?php echo (isset($_REQUEST['email'])?$_REQUEST['email']:""); ?>" />
						<div class="message"><?php echo (isset($message_email)?$message_email:""); ?></div>
					</div>
					<div class="form">
						*Inquiry<br />
						<textarea name="enquiry" cols="34" rows="10"><?php echo (isset($_REQUEST['enquiry'])?$_REQUEST['enquiry']:""); ?></textarea>
						<div class="message"><?php echo (isset($message_enquiry)?$message_enquiry:""); ?></div>
					</div>
					<div class="form">
						*Required
					</div>
					<div class="form">
						<input type="submit" value="submit" />
					</div>
				</form>
			</div>
		</div>
	</body>
</html>